import Vue from 'vue'
import VueRouter from 'vue-router'
import slot_cc from '../views/slot/slot_cc'

console.log(slot_cc)
Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'index',
        component: () => import('../views/index.vue'),
        redirect: '/router/滚动',
    },
    {
        path: '/slot',
        name: 'slot',
        component: () => import('../views/slot/index'),
        children: [
            {
                path: 'slot_cc',
                name: 'slot_cc',
                component: slot_cc
            }
        ]
    },
    {
        name: 'router',
        path: '/router',
        children: [
            {
                name: '滚动',
                path: '滚动',
                component: () => import('../views/vue-router/滚动'),
                children: [
                    {
                        name: '平滑滚动to',
                        path: 'ph_scroll_to',
                        component: () => import('../views/vue-router/滚动/平滑滚动to')
                    },
                    {
                        name: '平滑滚动from',
                        path: 'ph_scroll_from',
                        component: () => import('../views/vue-router/滚动/平滑滚动from')
                    },
                    {
                        name: '异步滚动to',
                        path: 'yb_scroll_to',
                        component: () => import('../views/vue-router/滚动/异步滚动to')
                    },
                    {
                        name: '异步滚动from',
                        path: 'yb_scroll_from',
                        component: () => import('../views/vue-router/滚动/异步滚动from')
                    },
                ]
            }
        ]
    },

]

const router = new VueRouter({
    mode: 'history',
    routes,
    scrollBehavior(to, from, savedPosition) {
        console.log(to,from,savedPosition)
        // return 期望滚动到哪个的位置
    }
})
router.beforeEach((to, from, next) => {
    console.log(to)
    console.log(from)
    next()
})

export default router
